package com.maybach.workflow.common.api.node;


import com.maybach.util.CollectionUtil;
import com.maybach.util.Transformer;
import com.maybach.workflow.common.api.enums.NodeTypeEnum;
import com.maybach.workflow.common.api.enums.TaskEnum;
import org.apache.commons.lang.StringUtils;

import java.util.List;

/**
 * Created by well on 15/6/9.
 */
public class TaskNode extends BaseNode {

    private List<TaskActor> actorList;

    private String executeBeanName;

    private String nextNodeName;

    private String url;
    private TaskEnum taskType;
    private List<String> beforeHandlers;
    private List<String> afterHandlers;

    public List<String> getBeforeHandlers() {
        return beforeHandlers;
    }

    public void setBeforeHandlers(String beforeHandlers) {
        if(StringUtils.isNotBlank(beforeHandlers)){
            this.beforeHandlers = CollectionUtil.transform(beforeHandlers.split(","), new Transformer<String, String>() {
                @Override
                public String transform(String object) {
                    return object;
                }
            });
        }
    }

    public List<String> getAfterHandlers() {
        return afterHandlers;
    }

    public void setAfterHandlers(String afterHandlers) {
        if(StringUtils.isNotBlank(afterHandlers)){
            this.afterHandlers = CollectionUtil.transform(afterHandlers.split(","), new Transformer<String, String>() {
                @Override
                public String transform(String object) {
                    return object;
                }
            });
        }
    }

    public TaskEnum getTaskType() {
        return taskType;
    }

    public void setTaskType(TaskEnum taskType) {
        this.taskType = taskType;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getNextNodeName() {
        return nextNodeName;
    }

    public void setNextNodeName(String nextNodeName) {
        this.nextNodeName = nextNodeName;
    }

    public String getExecuteBeanName() {
        return executeBeanName;
    }

    public void setExecuteBeanName(String executeBeanName) {
        this.executeBeanName = executeBeanName;
    }


    public List<TaskActor> getActorList() {
        return actorList;
    }

    public void setActorList(List<TaskActor> actorList) {
        this.actorList = actorList;
    }

    @Override
    public NodeTypeEnum getNodeType() {
        return NodeTypeEnum.task;
    }
}
